/**
 * 
 */
package com.chinamobile.maps.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.chinamobile.maps.dao.ITelecomoperatorsDAO;
import com.chinamobile.maps.orm.Accesslogs;
import com.chinamobile.maps.orm.Telecomoperators;

/**
 * @author FrankWong
 *
 */
public class TelecomoperatorsDAOImpl extends HibernateDaoSupport implements
		ITelecomoperatorsDAO {

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.ITelecomoperatorsDAO#addTelecomoperators(com.chinamobile.maps.orm.Telecomoperators)
	 */
	@Override
	public void addTelecomoperators(Telecomoperators telecomoperators) {
		this.getHibernateTemplate().save(telecomoperators);
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.ITelecomoperatorsDAO#delTelecomoperators(com.chinamobile.maps.orm.Telecomoperators)
	 */
	@Override
	public void delTelecomoperators(Telecomoperators telecomoperators) {
		this.getHibernateTemplate().delete(telecomoperators);
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.ITelecomoperatorsDAO#delTelecomoperators(int)
	 */
	@Override
	public void delTelecomoperators(int id) {
		this.getHibernateTemplate().delete(getTelecomoperatorsById(id));
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.ITelecomoperatorsDAO#updateTelecomoperators(com.chinamobile.maps.orm.Telecomoperators)
	 */
	@Override
	public void updateTelecomoperators(Telecomoperators telecomoperators) {
		this.getHibernateTemplate().update(telecomoperators);
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.ITelecomoperatorsDAO#getTelecomoperators()
	 */
	@Override
	public List<Telecomoperators> getTelecomoperators() {
		List list = this.getHibernateTemplate().find("from Telecomoperators");
		if (list != null && list.size() > 0) {
			return list;
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.ITelecomoperatorsDAO#getTelecomoperatorsById(int)
	 */
	@Override
	public Telecomoperators getTelecomoperatorsById(int id) {
		List list = this.getHibernateTemplate().find("from Telecomoperators as telecomoperators where telecomoperators.id=?",
				new Object[] { id });

		if (list != null && list.size() > 0) {
			return (Telecomoperators) list.get(0);
		}
		return null;
	}

}
